Skip to content

OpenVINO IR model export - #1238

Open
avbelova wants to merge 12 commits into
roboflow:developfrom
avbelova:openvino_export
Open

OpenVINO IR model export#1238
avbelova wants to merge 12 commits into
roboflow:developfrom
avbelova:openvino_export

Conversation

@avbelova

@avbelova avbelova commented Jul 27, 2026

Copy link
Copy Markdown

What does this PR do?

This PR adds RF-DETR model export to OpenVINO IR (Intermediate Representation).

Type of Change

  • New feature (non-breaking change that adds functionality)
  • Documentation update

Testing

  • I have tested this change locally
  • I have added/updated tests for this change

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have updated the documentation accordingly (if applicable)

ref: #1024

avbelova added 6 commits July 23, 2026 15:23
- Resolved conflicts in src/rfdetr/detr.py
- Combined OpenVINO and ExecuTorch export features
- Updated format documentation to include both openvino and executorch
- Updated return type to include .xml (OpenVINO) and .pte (ExecuTorch)
- Both formats now use direct conversion (no ONNX intermediate)
- Merged upstream changes: ExecuTorch export, dataset improvements, CI updates
- Added [openvino] optional dependency to pyproject.toml
- Updated all error messages to use 'pip install "rfdetr[openvino]"'
- Updated OpenVINO export documentation with new installation instructions
- Consistent with other optional dependencies (onnx, tflite, executorch, tensorrt)
- Update OpenVINO IR description to mention broader hardware support
- Mention CPU (x86, ARM), GPU (Intel integrated & discrete), and AI accelerators (Intel NPU)
- Make documentation more neutral and less Intel-specific
- Simplify installation instructions
- Remove redundant advantages section
@CLAassistant

CLAassistant commented Jul 27, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ Borda
❌ avbelova
You have signed the CLA already but the status is still pending? Let us recheck it.

@socket-security

socket-security Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedpypi/​openvino@​2026.3.17810010010070

View full report

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 3.22581% with 120 lines in your changes missing coverage. Please review.
✅ Project coverage is 57%. Comparing base (6674d85) to head (1a218ae).

❌ Your patch check has failed because the patch coverage (3%) is below the target coverage (95%). You can increase the patch coverage or adjust the target coverage.
❌ Your project check has failed because the head coverage (57%) is below the target coverage (95%). You can increase the head coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (6674d85) and HEAD (1a218ae). Click for more details.

HEAD has 27 uploads less than BASE
Flag BASE (6674d85) HEAD (1a218ae)
py3.11 2 0
cpu 9 0
Linux 6 1
py3.13 3 0
py3.10 3 0
py3.12 2 1
Windows 2 0
macOS 2 0
Additional details and impacted files
@@            Coverage Diff            @@
##           develop   #1238     +/-   ##
=========================================
- Coverage       86%     57%    -29%     
=========================================
  Files          114     116      +2     
  Lines        14880   14999    +119     
=========================================
- Hits         12835    8533   -4302     
- Misses        2045    6466   +4421     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Borda

Borda commented Jul 27, 2026

Copy link
Copy Markdown
Member

Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

@avbelova could you ls check ^^ 🦝

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new OpenVINO IR export path to RF-DETR, enabling direct PyTorch → OpenVINO conversion and documenting how to use the exported artifacts.

Changes:

  • Added an OpenVINO exporter and a small inference wrapper under src/rfdetr/export/_openvino/.
  • Integrated format="openvino" into RFDETR.export() and added an openvino optional dependency extra.
  • Updated export documentation to include OpenVINO IR export usage and examples.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/rfdetr/export/_openvino/README.md New OpenVINO export usage guide and inference examples.
src/rfdetr/export/_openvino/inference.py Adds a lightweight OpenVINO IR inference wrapper.
src/rfdetr/export/_openvino/exporter.py Implements direct PyTorch → OpenVINO IR conversion and saving.
src/rfdetr/export/_openvino/init.py Declares the OpenVINO export utilities package.
src/rfdetr/detr.py Extends RFDETR.export() to support format="openvino".
pyproject.toml Adds openvino optional dependency extra.
docs/learn/export.md Documents OpenVINO IR export workflow and examples.
Comments suppressed due to low confidence (2)

src/rfdetr/export/_openvino/README.md:88

  • The inference example loads output/inference_model.xml, but for RFDETRMedium the exporter will write output/rfdetr-medium.xml by default (because variant_name=self.size). This example should use the correct filename to avoid a copy/paste FileNotFoundError.
# Load the exported model
model = OpenVINOInference("output/inference_model.xml")

src/rfdetr/export/_openvino/README.md:113

  • The benchmark_app example uses output/inference_model.xml, but the default filename for RFDETRMedium export is output/rfdetr-medium.xml (because variant_name=self.size). Update the command so it works as written.
```bash
benchmark_app -m output/inference_model.xml -data_shape [1,3,576,576]
</details>

Comment thread src/rfdetr/export/_openvino/exporter.py Outdated
Comment on lines +59 to +62
if variant_name is not None:
export_name = f"{variant_name}-backbone" if backbone_only else variant_name
else:
export_name = "backbone_model" if backbone_only else "inference_model"
Comment on lines +71 to +74
# Ensure model is in eval mode and on CPU
model.eval()
model = model.cpu()
input_tensors = input_tensors.cpu()
Comment on lines +91 to +95
output = self.model(x)

# Handle backbone-only case (returns tensor directly)
if not isinstance(output, dict):
return (output,)
# Initialize OpenVINO runtime
core = ov.Core()
self.model = core.read_model(model_path)
self.compiled_model = core.compile_model(self.model, "CPU")
Comment thread src/rfdetr/export/_openvino/README.md Outdated
Comment on lines +32 to +35
This will create two files:

- `output/inference_model.xml` - The OpenVINO IR model
- `output/inference_model.bin` - The model weights
Comment thread docs/learn/export.md Outdated
Comment on lines +485 to +488
This produces two files:

- `output/rfdetr-medium.xml` - The model structure (Intermediate Representation)
- `output/rfdetr-medium.bin` - The model weights
Comment thread src/rfdetr/detr.py
Comment on lines +1618 to +1622
if format == "openvino":
try:
from rfdetr.export._openvino.exporter import export_openvino
except ImportError:
logger.error(
pre-commit-ci Bot and others added 3 commits August 31, 2026 14:08
- Add path traversal sanitization for variant_name parameter
- Call model.export() before OpenVINO conversion to ensure proper export mode
- Handle tuple outputs explicitly in ModelWrapper to prevent incorrect nesting
- Use AUTO device selection instead of hardcoded CPU for better performance
- Update documentation to reflect actual output filenames (rfdetr-medium.xml)
@avbelova

Copy link
Copy Markdown
Author

Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

@avbelova could you ls check ^^ 🦝

@Borda the corporate CLA is signed between Roboflow and Intel

@Borda

Borda commented Aug 31, 2026

Copy link
Copy Markdown
Member

Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

@avbelova could you ls check ^^ 🦝

@Borda the corporate CLA is signed between Roboflow and Intel

Perfect! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants